<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>vue</title>
		<script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
	</head>
	<body>
		<div id="app">
			<div>不超过9个字符：{{name}}</div>
			<div>超出9个字符|本地过滤器：{{title|substr()}}</div>
		</div>

		<script>
			new Vue({
				el: '#app',
				data() {
					return {
						name: '旺旺碎冰冰',
						title: "每天编程一小时大型IT公益活动"
					}
				},
				filters: {
					substr(title) {
						if (title.length > 9) {
							return title.substr(0, 9) + "......"
						}
						return title
					}
				}
			})
		</script>
	</body>
</html>
